<?php

include dirname(dirname(__FILE__)) . '/util/BuildSqlUtils.php';
include dirname(dirname(__FILE__)) . '/dao/impl/MySQLDaoImpl.php';
index();
function index() {
	BuildSqlUtilsTest::testBuildInsertSql();
}

class BuildSqlUtilsTest {

	/**
	 * 构造insert的sql
	 */
	public static function testBuildInsertSql() {
		function shutdown_function() {
			$e = error_get_last();
			print_r($e);
		}

		$tableName = "user";
		register_shutdown_function('shutdown_function');
		print_r($tableName);
		$entityArray = array("id" => 1, "username" => 'admin', "des" => null);
		$query = BuildSqlUtils::buildInsertSql($tableName, $entityArray);
		$mysql = new MySQLDaoImpl(dirname(dirname(__FILE__)) . '/config/config2.php');
		$m = array();
		try {
			print_r($query);
			$result = $mysql -> execute($query);
			print_r("ss");
			print_r($result);
			$m["success"] = true;
		} catch(Exception $e) {
			$msg = $e->getMessage();
			$m["success"] = false;
			$m["msg"] = $msg;
		}
		$e = error_get_last();
		print_r("test");
		print_r($e);
		print_r($m);

	}

	public static function testBulidUpdateSql() {
		$tableName = "user";
		$entityArray = array(id => 1, username => 'admin');
		$condition = "id='1'";
		$result = BuildSqlUtils::bulidUpdateSql($tableName, $entityArray, $condition);
		print_r($result);

	}

}
?>